package com.itheima.反射.Constructor;

import java.lang.reflect.Constructor;

public class Demo5 {
    public static void main(String[] args) throws Exception {
        //获取字节码对象
        Class aClass = Class.forName("java.lang.Math");
        //获取构造器
        Constructor declaredConstructor = aClass.getDeclaredConstructor();
        //暴力反射
        declaredConstructor.setAccessible(true);
        //基于构造器对象创建类的对象
        Math math = (Math) declaredConstructor.newInstance();
        double num = math.random() * 100 + 1;
       // System.out.println("num = " + num);
        System.out.println((int)num);

    }
}
